from django.core.serializers import serialize
from rest_framework import serializers

from application.models import Student


class StudentSerializer(serializers.Serializer):
    name = serializers.CharField(help_text='姓名',max_length=100,required=True)
    age = serializers.IntegerField(help_text='年龄',min_value=1,max_value=150)
    def create(self, validated_data):
        student = Student.objects.create(**validated_data)
        return student
